from flask import Blueprint, request, jsonify
from services.model_call_service import ModelCallService

model_calls_bp = Blueprint('model_calls_bp', __name__)

@model_calls_bp.route("/model-calls", methods=['GET'])
def get_model_calls():
    try:
        start_date = request.args.get('start_date')
        end_date = request.args.get('end_date')
        
        service = ModelCallService()
        records = service.get_model_calls(start_date, end_date)
        return jsonify(records)
        
    except Exception as e:
        return jsonify({"error": str(e)}), 500
